package com.pattern.adapter.springmvc;

/**
 * @author 冯志立
 * @create 2019-10-25 17:41
 */
//定义一个Adapter接口
public interface HanderAdapter {
    public boolean supports(Object handler);

    public void handle(Object handler);
}

//多种适配器类

class SimpleHandlerAdapter implements HanderAdapter{

    @Override
    public boolean supports(Object handler) {
        return (handler instanceof SimpleController);
    }

    @Override
    public void handle(Object handler) {
        ((SimpleController)handler).doSimpleHandler();
    }
}

class HttpHandlerAdapter implements HanderAdapter{

    @Override
    public boolean supports(Object handler) {
        return (handler instanceof HttpController);
    }

    @Override
    public void handle(Object handler) {
        ((HttpController)handler).doHttpHandler();
    }
}

class AnnotationHandlerAdapter implements HanderAdapter{

    @Override
    public boolean supports(Object handler) {
        return (handler instanceof AnnotationController);
    }

    @Override
    public void handle(Object handler) {
        ((AnnotationController)handler).doAnnotationHandler();
    }
}